package com.bwie.controller;

import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginVo;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @description :
 * @Author QiHainan
 * @Create 2025/6/19 19:06
 * @Version 1.0
 */
@RestController
@RequestMapping("/user/index")
public class IndexController {
    @Autowired
    TbUserService tbUserService;

    /**
     * 登录
     * @param loginVo
     * @return
     */
    @PostMapping("/adminLogin")
    public R adminLogin(@RequestBody @Validated LoginVo loginVo){
        return tbUserService.adminLogin(loginVo);
    }

    /**
     * 根据用户ID获取权限
     * @return
     */
    @PostMapping("/getMenuTree")
    public R getMenuTree(){
        return tbUserService.getMenuTree();
    }

    /**
     * 获取商家分页列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getUserList")
    public R getUserList(@RequestBody PageInfoVo pageInfoVo){
        return tbUserService.getUserList(pageInfoVo);
    }

    /**
     * 获取当前登录用户的信息
     * @return
     */
    @PostMapping("/getUserInfo")
    public R getUserInfo(){
        return tbUserService.getUserInfo();
    }

    /**
     * 获取用户信息
     * @param userId
     * @return
     */
    @PostMapping("/getUserInfoById/{userId}")
    public R getUserInfoById(@PathVariable("userId") Integer userId){
        return tbUserService.getUserInfoById(userId);
    }

    /**
     * 用户签到
     * @return
     */
    @PostMapping("/signIn")
    public R signIn(){
        return tbUserService.signIn();
    }

    @PostMapping("/joinActiveSubScore/{userId}/{score}")
    public R joinActiveSubScore(@PathVariable("userId") Integer userId,@PathVariable("score") Integer score){
        return tbUserService.joinActiveSubScore(userId,score);
    }
}
